//
// Created by ZLY on 2025/5/11.
//

#include "affiliateBar.h"


AffiliateBar *AffiliateBar::
addAffiliateBarChild(ObjectScreen *parent, glm::vec2 size, glm::vec2 offset, Anchor anchor) {
    auto bar = new AffiliateBar();
    bar->init();
    bar->setSize(size);
    bar->setAnchor(anchor);
    if (parent) {
        parent->addChild(bar);
        bar->setParent(parent);
    }
    return bar;
}

void AffiliateBar::render() {
    auto pos = parent_->getRenderPos() + offset_;
    if (percentage_ > 0.7f) {
        game_.renderHBar(pos, size_, percentage_, color_high_);
    } else if (percentage_ > 0.3f) {
        game_.renderHBar(pos, size_, percentage_, color_mid_);
    } else {
        game_.renderHBar(pos, size_, percentage_, color_low_);
    }
}
